var app = new Vue({
    el:"#app",
    data: {
        // username: sessionStorage.username || localStorage.username,
        user_id: sessionStorage.user_id || localStorage.user_id,
        user_img_url:sessionStorage.img_url || localStorage.img_url,
        token: sessionStorage.token || localStorage.token,
        base,
        title: "",
        label: "",
        content: "",
        username:1


        },
        computed: {
            // 需要通过计算得到的数据，键值对 ，键是名称，值是匿名函数
        },
        mounted: function () {
            CKEDITOR.replace('editor1');
            // alert('haha')

            // axios.get(this.base + '/submit/', {
            //
            //     responseType: 'json',
            //
            // })
            // .then(response => {
            //     console.info(response.data),
            //     alert('hahaha')
            //
            //
            //
            // })
            // .catch(error => {
            //     //
            //     alert('出错了')
            // })

        },
        methods: {
            submit_question:function () {
        //    获取表单的标题
        //    获取表单分类的id
        //    获取标签也就是摘要
        //    获取文本域内容
            var content_edict = CKEDITOR.instances.editor1.getData();
            axios.post(this.base+'/submit/',{
                title:this.title,
                label:1,
                content:content_edict,
                author:this.user_id
            })
            .then(response =>{
                alert("提交成功！");
                window.location.href='http://127.0.0.1:8080/qa-logined.html'
            })
            .catch(error => {
                console.log(error)
            })
        }
        }
    })/**
 * Created by python on 18-11-9.
 */


